package com.dys.test01;

import com.dys.calculator.Calculator;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @className: com.dys.test01.CalculatorTest
 * @description: com.dys.test01
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/08/25 下午9:01
 */
public class CalculatorTest {

    @Before
    public void init() {
        System.out.println("测试方法执行开始了......");
    }

    @After
    public void close() {
        System.out.println("测试方法执行结束了......");
    }

    /**
     * 测试相加的方法
     */
    @Test
    public void testAdd() {
        Calculator calc = new Calculator();
        int result = calc.add(99, 1);
        System.out.println(result);
    }

    /**
     * 测试添加的方法,加入断言
     */
    @Test
    public void testAdd11() {
        Calculator calc = new Calculator();
        int result = calc.add11(99, 1);
        Assert.assertEquals(100, result);
    }

    /**
     * 测试相加逻辑错误
     */
    @Test
    public void testAdd2() {
        Calculator calc = new Calculator();
        int result = calc.add2(10, 20);
        System.out.println(result);
    }

    /**
     * 测试相加异常
     */
    @Test
    public void testAdd3() {
        Calculator calc = new Calculator();
        int result = calc.add3(10, 20);
        System.out.println(result);
    }

    /**
     * 测试相减的方法
     */
    @Test
    public void testSub() {
        Calculator calc = new Calculator();
        int result = calc.sub(99, 1);
        Assert.assertEquals(98, result);
        System.out.println(result);
    }
}
